<?php
session_start(); //开启会话
?>
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>会员登录日志</title>
        <style>
            html{width: 100%; height: 100%;}

            h1 {
                color: white;
                padding-top: 2%;
                /*position: absolute;*/
                /*top: 6%;*/
                /*left: 8%;*/
            }
            table{

                background-color: rgba(255, 150, 41, 0.8);
            }
            b{
                font-size: 20px;
                margin-left: 30px;
                color: rgba(255, 138, 36, 0.7)
            }
            .box{
                background-color: rgba(255, 255, 255, 0.46);
                border-radius:25px;
                margin: 0 auto;
                padding: 0 auto;
                align-content: center;


            }
            h2{
                text-align: center
            }
            #boxs {
                position: absolute;
                top: 180px;
                width: 100%;
                margin-top: 7%;
            }
            td {
                padding: 12px;
            }

            body{

                background-color: #00BDDC;


                background-size: 100% 100%;
                /*overflow:scroll;*/
                /*overflow-y:hidden;*/
            }

            a{
                color: #6278eb;
                text-decoration: none;
            }


        </style>
    </head>

    <body>
    <h1>汽车在线投票系统<b>会员登录日志</b></h1>
    <?php
    //先判断是否管理员登录，本页面只有管理员才能访问
    if (!isset($_SESSION['admin']) or !$_SESSION['admin']) {  //说明未登录  isset（）检测变量是否设置，并且不是 NULL
        echo "<script>alert('本页面需要管理员才能访问，请以管理员身份登录！');location.href='in.php';</script>";
        exit;
    }
    include_once "conn.php";
    $sql = "select username,loggeddate from log,userinfo where log.userid = userinfo.id order by log.id desc";
    $result = mysqli_query($conn,$sql);

    include_once "page.php";
    $count_rows = mysqli_num_rows($result);
    $perPage = 6;
    pageft($count_rows, $perPage, $count_rows);
    $sql .=" limit $firstcount, $displaypg";
    $result = mysqli_query($conn,$sql);
    ?>
    <div id="boxs"  align="center">
        <table align="center" class="box" >
        <tr>
                 <td>
                <table  align="center" style="border-collapse: collapse" border="1" bordercolor="#FFF"width="90%">
                            <td>序号</td>
                            <td>用户名</td>
                            <td>登录时间</td>
                            </tr>
                            <?php
                            $page = isset($_GET['page']) ? $_GET['page'] : 1;
                            $i = ($page - 1) * $perPage + 1;
                            while($info = mysqli_fetch_array($result)){
                                ?>
                                <tr>
                                    <td><?php echo $i?></td>
                                    <td><?php echo $info['username']?></td>
                                    <td><?php ini_set('date.timezone', 'PRC');echo date("Y-m-d H:i:s",$info['loggeddate']);?></td>
                                </tr>
                                <?php
                                $i++;
                            }
                            ?>
                </table>
                 </td>
             </tr>
        <tr>
            <td align="center"><?php
                //页尾显示
                echo $pagenav;
                ?>
                <span style="margin-left: 10px"><a href="index.php"> 返回</a></span></h2>
            </td>
        </tr>
    </table>
    </div>
    <div class="snow"></div>
    </body>
    </html>

<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/21
 * Time: 9:41
 */